codeStr = "";
pubPass = "BX1o65CoobwcDP33iQW6ld1OyIPsNzF1";
pubPassNum = [];
publicKey = "";


random = function (e, t) {
    return void 0 === e && (e = 0),
        void 0 === t && (t = 1e4),
        Math.round(Math.random() * (t - e) + e)
}

randomStr = function (e) {
    for (var t = [], n = 0; n < e; n++)
        t.push(random(0, 35).toString(36));
    return t.join("")
}


uuid = function (t, n) {
    void 0 === t && (t = 16),
        void 0 === n && (n = !1),
        !n && t < 16 && (console.error("uuid useCase=false 时 len 不能小于 16"),
            t = 16),
        n && t < 12 && (console.error("uuid useCase=true 时 len 不能小于 12"),
            t = 12);
    var i = ((new Date).getTime() + 1e14).toString();
    e = NaN;
    return i += ("000" + (++e.uuidCount).toString()).substr(-3, 3),
        i = n ? parseInt(i).to62() : parseInt(i).toString(36),
        i += randomStr(t),
        i = i.substr(0, t),
        i
}



stringChangeASCIINumberArrs = function (e) {
    for (var t = [], n = 0; n < e.length; n++)
        t.push(e.charCodeAt(n));
    return t
}

setPass = function (e) {
    pubPassNum = stringChangeASCIINumberArrs(e)

}
setPass(pubPass)


encryptCode = function (e) {
    for (var t = encodeURI(e), n = [], i = 0, r = "", o = random(16, 32), a = randomStr(o), s = stringChangeASCIINumberArrs(a), l = 0, c = 0, u = 0, h = 0; h < t.length; h++)
        i = t.charCodeAt(h),
            l == this.pubPassNum.length && (l = 0),
            i += this.pubPassNum[l],
            l++,
            c == s.length && (c = 0),
            i += s[c],
            c++,
            u += i,
            u > 65535 && (u -= 65535),
            r = i.toString(36),
            r = ("00" + r).substr(-2, 2),
            1 == r.length && (r = "0" + r),
            n.push(r);
    var d = "";
    return d = u.toString(36),
        d = ("0000" + r).substr(-4, 4),
        n.unshift(a),
        n.unshift(o.toString(36)),
        n.unshift(d),
        n.join("")
}

encode = function (e) {
    var t = "";
    try {
        t = JSON.stringify(e)
    } catch (n) {
        return console.error(n + "这不是一个正确的json对象"),
            ""
    }
    return encryptCode(t)
}


decryptCode = function (e) {
    var t = ""
        , n = 0
        , i = ""
        , r = []
        , o = []
        , a = 0
        , s = 0;
    t = e.substr(4, 1),
        n = parseInt(t, 36),
        i = e.substr(5, n),
        r = stringChangeASCIINumberArrs(i),
        t = e.substr(5 + n, e.length - 5 - n);
    for (var l = "", c = 0, u = 0, h = 0; h < t.length / 2; h++)
        l = t.substr(u, 2),
            u += 2,
            c = parseInt(l, 36),
            s == r.length && (s = 0),
            c -= r[s],
            s++,
            a == this.pubPass.length && (a = 0),
            c -= this.pubPassNum[a],
            a++,
            l = String.fromCharCode(c),
            o.push(l);
    return t = o.join(""),
        t = decodeURI(t),
        t
}

function encrypt() {
    o = {
        "id": uuid(),
        "projectKey": "honsan_cloud_ccprec",
        "clientKey": uuid(),
        "token": null,
        "clientDailyData": {},
        "acts": [
            {
                "id": uuid(),
                "fullPath": "/ccprec.com.cn.web/client/info/cqweb_nonphy_cqzr",
                "args": [
                    1,
                    20,
                    null
                ]
            }
        ]
    }
    return encode(JSON.stringify(o))
}

